import request from '@/utils/request'
// import qs from 'qs'

// 黑名单

// 静态黑名单

// 删除静态黑名单
export function delStaticBlack (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/delStaticBlack',
    method: 'post',
    data
  })
}

// 添加静态黑名单
export function addStaticBlack (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/addStaticBlack',
    method: 'post',
    data
  })
}

// 清空静态黑名单
export function clearStaticBlack (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/clearStaticBlack',
    method: 'post',
    data
  })
}

// 获取静态黑名单列表
export function getStaticBlacklist (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/getStaticBlacklist',
    method: 'post',
    data
  })
}

// 动态黑名单

// 删除动态黑名单
export function delDynamicBlack (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/delDynamicBlack',
    method: 'post',
    data
  })
}

// 添加动态黑名单
export function addDynamicBlack (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/addDynamicBlack',
    method: 'post',
    data
  })
}

// 获取动态黑名单列表
export function getDynamicBlacklist (params) {
  var data = fromData(params)
  return request({
    url: '/blacklist/getDynamicBlacklist',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
